﻿using System;
using System.ComponentModel;
using System.Web.UI;
using System.Collections;
using System.Collections.Generic;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.Core;

namespace Yuanlin.Business
{
    public class CompanyProjectDetail : YuanlinUserControl,
        IReplyConverter<CompanyProjectReply, GetOperation>
    {
        protected Repeater list;
        private CompanyProject companyProject;

        public override void GetRequests(List<BaseRequestBinder> requestBinders)
        {
            requestBinders.Add(RequestHelper.BuildGetCompanyProjectRequest(this));
        }

        private void BindData()
        {
            EntityList companyProjects = new EntityList()  ;

            if (companyProject != null)
            {
                companyProjects.Add(companyProject);
            }

            list.DataSource = companyProjects;
            list.DataBind();
        }

        #region IReplyConverter<CompanyProjectReply,GetOperation> Members

        public void ConvertReply(CompanyProjectReply reply, GetOperation operation)
        {
            if (reply != null)
            {
                companyProject = reply.Entity as CompanyProject;

                if (!IsPostBack)
                {
                    BindData();
                }
            }
        }

        #endregion
    }
}
